from moviepy.editor import *


class videotogif:
    def __init__(self, file_path, out_gif_path):
        self.file_path = file_path
        self.out_gif_path = out_gif_path

    def togif(self):
        clip = VideoFileClip(self.file_path)
        # clip = clip.set_duration(clip.duration)
        clip = clip.resize(0.3)
        clip = clip.set_duration(clip.duration)
        clip.write_gif(self.out_gif_path, fps=8)


if __name__ == "__main__":
    videotogifo = videotogif("C:/Users/long/测试新注册账户第一次登陆失败20201208_094644.mp4", "C:/Users/long/Desktop/out.gif")
    videotogifo.togif()
